import 'dart:math';

import 'package:flutter/material.dart';

class ColorsUtil {
  static const Color COLOR_F7F8FA = Color(0xffF7F8FA);
  static const Color COLOR_CDA4FF = Color(0xffe7a6a6);
  static const Color COLOR_FF5C5C = Color(0xffFF5C5C);
  static const Color COLOR_333333 = Color(0xff333333);
  static const Color COLOR_666666 = Color(0xff666666);
  static const Color COLOR_999999 = Color(0xff999999);
  static const Color COLOR_AAAAAA = Color(0xffAAAAAA);
  static const Color COLOR_DBDBDB = Color(0xffDBDBDB);
  static const Color COLOR_FFFFFF = Color(0xffFFFFFF);
  static const Color COLOR_EBEBEB = Color(0xffEBEBEB);
  static const Color COLOR_TRANSPARENT = Colors.transparent;

  static Color alphaColorFF5C5C(int alpha) {
    int num = 255 * alpha ~/ 100;
    return Color.fromARGB(num, 255, 92, 92);
  }

  static Color alphaColor000000(int alpha) {
    int num = 255 * alpha ~/ 100;
    return Color.fromARGB(num, 0, 0, 0);
  }

  static Color randomColor() {
    Random random = Random();

    // 水的颜色通常是由蓝色和绿色混合而成的
    int red = random.nextInt(64); // 红色值通常较低
    int green = random.nextInt(256); // 绿色值可以在较大范围内变化
    int blue = random.nextInt(256); // 蓝色值也可以在较大范围内变化

    // 为了让颜色看起来更像水，我们可以增加一些随机性，让蓝色和绿色更加突出
    if (random.nextBool()) {
      blue += 64; // 增加蓝色值，使颜色更偏向于蓝色
    } else {
      green += 64; // 增加绿色值，使颜色更偏向于绿色
    }

    // 确保颜色值在有效范围内
    red = red.clamp(0, 255);
    green = green.clamp(0, 255);
    blue = blue.clamp(0, 255);

    // 返回生成的水一样的颜色
    return Color.fromARGB(255, 165, 187, 220);
  }
}